package com.house.system.service.impl;

import java.util.Calendar;
import java.util.List;

import com.house.common.annotation.DataScope;
import com.house.common.utils.DateUtils;
import com.house.system.domain.Contract;
import com.house.system.mapper.ContractMapper;
import com.house.system.mapper.HouseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.house.system.mapper.PayMapper;
import com.house.system.domain.Pay;
import com.house.system.service.IPayService;

import javax.annotation.PostConstruct;

/**
 * 缴纳租金Service业务层处理
 *
 * @author tc
 * @date 2022-02-25
 */
@Service
public class PayServiceImpl implements IPayService {
    @Autowired
    private PayMapper payMapper;

    @Autowired
    private ContractMapper contractMapper;

    @Autowired
    private HouseMapper houseMapper;

    /**
     * 查询缴纳租金
     *
     * @param payId 缴纳租金主键
     * @return 缴纳租金
     */
    @Override
    public Pay selectPayByPayId(Long payId) {
        return payMapper.selectPayByPayId(payId);
    }

    /**
     * 查询缴纳租金列表
     *
     * @param pay 缴纳租金
     * @return 缴纳租金
     */
    @Override
    public List<Pay> selectPayList(Pay pay) {
        return payMapper.selectPayList(pay);
    }

    /**
     * 新增缴纳租金
     *
     * @param pay 缴纳租金
     * @return 结果
     */
    @Override
    public int insertPay(Pay pay) {
        pay.setCreateTime(DateUtils.getNowDate());
        return payMapper.insertPay(pay);
    }

    /**
     * 修改缴纳租金
     *
     * @param pay 缴纳租金
     * @return 结果
     */
    @Override
    public int updatePay(Pay pay) {
        pay.setUpdateTime(DateUtils.getNowDate());
        pay.setStatus("1");
        pay.setPayTime(DateUtils.getNowDate());
        return payMapper.updatePay(pay);
    }

    /**
     * 批量删除缴纳租金
     *
     * @param payIds 需要删除的缴纳租金主键
     * @return 结果
     */
    @Override
    public int deletePayByPayIds(Long[] payIds) {
        return payMapper.deletePayByPayIds(payIds);
    }

    /**
     * 删除缴纳租金信息
     *
     * @param payId 缴纳租金主键
     * @return 结果
     */
    @Override
    public int deletePayByPayId(Long payId) {
        return payMapper.deletePayByPayId(payId);
    }

}
